﻿using System;
using System.Collections;
using UnityEngine;

namespace Gp.Scripts.Core {
    [Serializable]
    public class SkillAnimationSet {
        public AnimationClip preState;
        public AnimationClip performState;
        public AnimationClip posState;


        public const string PreStateName = "Pre State";
        public const string PerformState = "Perform State";
        public const string PostState = "Post State";



        public void Apply(AnimatorOverrideController overrideController) {
            overrideController[PreStateName] = preState;
            overrideController[PerformState] = performState;
            overrideController[PostState] = posState;
        }



        public bool IsEmpty() {
            return preState == null && performState == null;
        }


        public IEnumerator FixTime(float startTime) {
            if (performState == null) yield break;
            
            var time = Time.time - startTime;
            var len = performState.length - time;
            if (len > 0)
                yield return new WaitForSeconds(len);
        }
        
        
    }
}